package cn.ppool.xmlmapper.builder.parse.model.func;

import cn.ppool.xmlmapper.builder.MapperBuilder;
import cn.ppool.xmlmapper.builder.parse.model.base.BaseFuncBO;
import cn.ppool.xmlmapper.builder.parse.model.base.BaseTest;
import cn.ppool.xmlmapper.builder.xml.XNode;
import lombok.extern.log4j.Log4j2;

import java.util.Map;

@Log4j2
public class IfBO extends BaseTest {
    public final static String TAG_NAME = "IF";


    @Override
    public void buildEntityModel() {

    }

    @Override
    public String complieEntity(Map<String, Object> allVar, Map<String, Object> sqlVar, StringBuilder sql, BaseFuncBO lastObject) {
        if (getFun() != null && getFun().equals(ELSE)) {
            return getContent(allVar, sqlVar);
        }
        return runTest(allVar) ? getContent(allVar, sqlVar) : "";
    }


    public IfBO(MapperBuilder configure, XNode parentNode, XNode currentNode) {
        super(configure, parentNode, currentNode);
    }
}
